main
Sub Main
	dim limit
	limit = inputbox("more than ?mm",limit,"0.2")
	limit=Val(limit)
	limit_mil =limit* 39.37
	
	dim doc
	set doc = application.activedocument
	Dim P
	P= SplitPath(doc.FullName)	
	logfile = p & "\log.txt"
	dim fso
	set fso = createobject("scripting.filesystemobject") 
	dim fw
	set fw = fso.createtextfile(logfile)
	fw.writeline(limit)
		
	
	Application.modelesscmd("zt")
	Application.modelesscmd("lt")
	Application.ExecuteCommand("Quick Filter Components")
	Application.ExecuteCommand("Select All")

	Application.ExecuteCommand("Properties")
	ComponentPropertiesDlg.Tab = "Labels"
	ComponentPropertiesDlg.ComponentPropertiesLabelDlg.LabelButton.Click()
	PartLabelPropertiesDlg.Attribute = "Geometry.Height"
	PartLabelPropertiesDlg.X = "0"
	PartLabelPropertiesDlg.Y = "0"
	PartLabelPropertiesDlg.Size = "25"
	PartLabelPropertiesDlg.LineWidth = "0"
	PartLabelPropertiesDlg.HorizontalJustification = "Center"
	PartLabelPropertiesDlg.VerticalJustification = "Center"
	PartLabelPropertiesDlg.Ok.Click()
	ComponentPropertiesDlg.Tab = "Labels"
	ComponentPropertiesDlg.Ok.Click()

	Application.ExecuteCommand("Display Colors Setup")
	DisplayColorsSetupDlg.SelectedColor.SetActive (15)
	DisplayColorsSetupDlg.ColorGrid.Cell("TOP", "Attributes") = "15"
	DisplayColorsSetupDlg.Ok.Click()

	Application.ExecuteCommand("Filter")
	SelectionFilterDlg.Nothing.Click()
	SelectionFilterDlg.SelectionObjectsDlg.Labels = true
	'SelectionFilterDlg.Tab = "Layer"
	'SelectionFilterDlg.SelectionLayersDlg.LayersList.Checked(4) = true 'doc.ElectricalLayerCount
	SelectionFilterDlg.Ok.Click()	
	
	Set objs = doc.GetObjects(15,,true)
	dim ncount
	ncount = 0
	for each obj in objs
		'msgbox obj.ObjectType
		'msgbox obj.name	
		if obj.name="Geometry.Height" then 		
			val1 = lcase(obj.text)
			val2 = replace(val1,"mm","")
			val3 = replace(val1,"mil","")
			'mm
			if val1=val2 then
			else
				'msgbox "neq"
				val2= Val(val2)
				fw.writeline(obj.component.name & chr(9) & obj.text & Str(val2-limit))
				'msgbox val2>=limit
				if val2-limit>=0 then
					obj.component.Selected =true
					ncount = ncount+1
				end if
			end if


			'mil		
			'msgbox val3 & "," & limit
			'msgbox val3-limit
			if val1=val3 then
			else
				'msgbox "neq"
				val3=Val(val3)
				fw.writeline(obj.component.name & chr(9) & obj.text & Str(val3-limit))
				if val3-limit_mil>=0 then
					obj.component.Selected =true
					ncount = ncount+1
				end if
			end if
		end if
	next
	msgbox ncount
	fw.close
	set fw = nothing
	set fso = nothing	
	wsh_run logfile
End Sub
sub wsh_run(value)
	dim wsh
	set wsh = createobject("wscript.shell")
	wsh.run value
	set wsh = nothing
end sub
function SplitPath(InString)
	Dim x,PathString, FileString
	For x = Len(InString) To 1 Step -1
		If Mid(InString, x, 1)="\" Then
			PathString = Left(InString, x)
			FileString = Right(InString, Len(InString) - x)
			Exit For
		End If
	Next x
	SplitPath = PathString
End function
